/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package net.siit.ling;

/**
 *
 * @author arthit
 */
public class Clause implements Comparable {
    public String subject = null;
    public String verb    = null;
    public String object  = null;
    public String context = null;

    @Override
    public String toString() {
        return ( subject == null ? "" : "[" + Annotation.SUBJECT + " " + subject + "]" ) +
               ( verb    == null ? "" : "[" + Annotation.VERB    + " " + verb    + "]" ) +
               ( object  == null ? "" : "[" + Annotation.OBJECT  + " " + object  + "]" ) +
               ( context == null ? "" : "[" + Annotation.CONTEXT + " " + context + "]" );
    }
    
    @Override
    public int compareTo(Object o) {
        if (o.getClass() != Clause.class)
            return 1;
        
        Clause c = (Clause) o;
        
        if ( ( ((verb == null) && (c.verb == null)) || verb.equals(c.verb) ) &&
             ( ((subject == null) && (c.subject == null)) || subject.equals(c.subject) ) &&
             ( ((object == null) && (c.object == null)) || object.equals(c.object) ) &&
             ( ((context == null) && (c.context == null)) || context.equals(c.context) ) ) 
            return 0;
        
        return -1;
    }

    public int hashCode() {
        int hash = 3;
        hash = 47 * hash + (this.subject != null ? this.subject.hashCode() : 0);
        hash = 47 * hash + (this.verb != null ? this.verb.hashCode() : 0);
        hash = 47 * hash + (this.object != null ? this.object.hashCode() : 0);
        hash = 47 * hash + (this.context != null ? this.context.hashCode() : 0);
        return hash;
    }
    
    public boolean equals(Object o) {
        if (this.compareTo(o) == 0)
            return true;
        return false;
    }    
    
}